\(\int (e \sec (c+d x))^{4-2 n} (a+i a \tan (c+d x))^n \, dx\) [493]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [F]
   Fricas [A] (verification not implemented)
   Sympy [F]
   Maxima [B] (verification not implemented)
   Giac [F]
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 30, antiderivative size = 98 \[ \int (e \sec (c+d x))^{4-2 n} (a+i a \tan (c+d x))^n \, dx=\frac {2 i a^2 (e \sec (c+d x))^{4-2 n} (a+i a \tan (c+d x))^{-2+n}}{d \left (6-5 n+n^2\right )}+\frac {i a (e \sec (c+d x))^{4-2 n} (a+i a \tan (c+d x))^{-1+n}}{d (3-n)} \]

[Out]

2*I*a^2*(e*sec(d*x+c))^(4-2*n)*(a+I*a*tan(d*x+c))^(-2+n)/d/(n^2-5*n+6)+I*a*(e*sec(d*x+c))^(4-2*n)*(a+I*a*tan(d
*x+c))^(-1+n)/d/(3-n)

Rubi [A] (verified)

Time = 0.17 (sec) , antiderivative size = 98, normalized size of antiderivative = 1.00, number of steps used = 2, number of rules used = 2, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.067, Rules used = {3575, 3574} \[ \int (e \sec (c+d x))^{4-2 n} (a+i a \tan (c+d x))^n \, dx=\frac {2 i a^2 (a+i a \tan (c+d x))^{n-2} (e \sec (c+d x))^{4-2 n}}{d \left (n^2-5 n+6\right )}+\frac {i a (a+i a \tan (c+d x))^{n-1} (e \sec (c+d x))^{4-2 n}}{d (3-n)} \]

[In]

Int[(e*Sec[c + d*x])^(4 - 2*n)*(a + I*a*Tan[c + d*x])^n,x]

[Out]

((2*I)*a^2*(e*Sec[c + d*x])^(4 - 2*n)*(a + I*a*Tan[c + d*x])^(-2 + n))/(d*(6 - 5*n + n^2)) + (I*a*(e*Sec[c + d
*x])^(4 - 2*n)*(a + I*a*Tan[c + d*x])^(-1 + n))/(d*(3 - n))

Rule 3574

Int[((d_.)*sec[(e_.) + (f_.)*(x_)])^(m_.)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Simp[2*b*(
d*Sec[e + f*x])^m*((a + b*Tan[e + f*x])^(n - 1)/(f*m)), x] /; FreeQ[{a, b, d, e, f, m, n}, x] && EqQ[a^2 + b^2
, 0] && EqQ[Simplify[m/2 + n - 1], 0]

Rule 3575

Int[((d_.)*sec[(e_.) + (f_.)*(x_)])^(m_.)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Simp[b*(d*
Sec[e + f*x])^m*((a + b*Tan[e + f*x])^(n - 1)/(f*(m + n - 1))), x] + Dist[a*((m + 2*n - 2)/(m + n - 1)), Int[(
d*Sec[e + f*x])^m*(a + b*Tan[e + f*x])^(n - 1), x], x] /; FreeQ[{a, b, d, e, f, m, n}, x] && EqQ[a^2 + b^2, 0]
 && IGtQ[Simplify[m/2 + n - 1], 0] &&  !IntegerQ[n]

Rubi steps \begin{align*} \text {integral}& = \frac {i a (e \sec (c+d x))^{4-2 n} (a+i a \tan (c+d x))^{-1+n}}{d (3-n)}+\frac {(2 a) \int (e \sec (c+d x))^{4-2 n} (a+i a \tan (c+d x))^{-1+n} \, dx}{3-n} \\ & = \frac {2 i a^2 (e \sec (c+d x))^{4-2 n} (a+i a \tan (c+d x))^{-2+n}}{d \left (6-5 n+n^2\right )}+\frac {i a (e \sec (c+d x))^{4-2 n} (a+i a \tan (c+d x))^{-1+n}}{d (3-n)} \\ \end{align*}

Mathematica [A] (verified)

Time = 2.56 (sec) , antiderivative size = 91, normalized size of antiderivative = 0.93 \[ \int (e \sec (c+d x))^{4-2 n} (a+i a \tan (c+d x))^n \, dx=\frac {e^4 \sec ^2(c+d x) (e \sec (c+d x))^{-2 n} (\cos (2 (c+d x))-i \sin (2 (c+d x))) (a+i a \tan (c+d x))^n (-i (-4+n)+(-2+n) \tan (c+d x))}{d (-3+n) (-2+n)} \]

[In]

Integrate[(e*Sec[c + d*x])^(4 - 2*n)*(a + I*a*Tan[c + d*x])^n,x]

[Out]

(e^4*Sec[c + d*x]^2*(Cos[2*(c + d*x)] - I*Sin[2*(c + d*x)])*(a + I*a*Tan[c + d*x])^n*((-I)*(-4 + n) + (-2 + n)
*Tan[c + d*x]))/(d*(-3 + n)*(-2 + n)*(e*Sec[c + d*x])^(2*n))

Maple [F]

\[\int \left (e \sec \left (d x +c \right )\right )^{4-2 n} \left (a +i a \tan \left (d x +c \right )\right )^{n}d x\]

[In]

int((e*sec(d*x+c))^(4-2*n)*(a+I*a*tan(d*x+c))^n,x)

[Out]

int((e*sec(d*x+c))^(4-2*n)*(a+I*a*tan(d*x+c))^n,x)

Fricas [A] (verification not implemented)

none

Time = 0.24 (sec) , antiderivative size = 134, normalized size of antiderivative = 1.37 \[ \int (e \sec (c+d x))^{4-2 n} (a+i a \tan (c+d x))^n \, dx=\frac {{\left ({\left (-i \, n + 3 i\right )} e^{\left (4 i \, d x + 4 i \, c\right )} + {\left (-i \, n + 4 i\right )} e^{\left (2 i \, d x + 2 i \, c\right )} + i\right )} \left (\frac {2 \, e e^{\left (i \, d x + i \, c\right )}}{e^{\left (2 i \, d x + 2 i \, c\right )} + 1}\right )^{-2 \, n + 4} e^{\left (i \, d n x + i \, c n - 4 i \, d x + n \log \left (\frac {2 \, e e^{\left (i \, d x + i \, c\right )}}{e^{\left (2 i \, d x + 2 i \, c\right )} + 1}\right ) + n \log \left (\frac {a}{e}\right ) - 4 i \, c\right )}}{2 \, {\left (d n^{2} - 5 \, d n + 6 \, d\right )}} \]

[In]

integrate((e*sec(d*x+c))^(4-2*n)*(a+I*a*tan(d*x+c))^n,x, algorithm="fricas")

[Out]

1/2*((-I*n + 3*I)*e^(4*I*d*x + 4*I*c) + (-I*n + 4*I)*e^(2*I*d*x + 2*I*c) + I)*(2*e*e^(I*d*x + I*c)/(e^(2*I*d*x
 + 2*I*c) + 1))^(-2*n + 4)*e^(I*d*n*x + I*c*n - 4*I*d*x + n*log(2*e*e^(I*d*x + I*c)/(e^(2*I*d*x + 2*I*c) + 1))
 + n*log(a/e) - 4*I*c)/(d*n^2 - 5*d*n + 6*d)

Sympy [F]

\[ \int (e \sec (c+d x))^{4-2 n} (a+i a \tan (c+d x))^n \, dx=\int \left (e \sec {\left (c + d x \right )}\right )^{4 - 2 n} \left (i a \left (\tan {\left (c + d x \right )} - i\right )\right )^{n}\, dx \]

[In]

integrate((e*sec(d*x+c))**(4-2*n)*(a+I*a*tan(d*x+c))**n,x)

[Out]

Integral((e*sec(c + d*x))**(4 - 2*n)*(I*a*(tan(c + d*x) - I))**n, x)

Maxima [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 595 vs. \(2 (88) = 176\).

Time = 1.08 (sec) , antiderivative size = 595, normalized size of antiderivative = 6.07 \[ \int (e \sec (c+d x))^{4-2 n} (a+i a \tan (c+d x))^n \, dx=\frac {8 \, {\left ({\left (\cos \left (2 \, d x + 2 \, c\right )^{2} + \sin \left (2 \, d x + 2 \, c\right )^{2} + 2 \, \cos \left (2 \, d x + 2 \, c\right ) + 1\right )}^{\frac {1}{2} \, n} a^{n} e^{4} \cos \left (n \arctan \left (\sin \left (2 \, d x + 2 \, c\right ), \cos \left (2 \, d x + 2 \, c\right ) + 1\right )\right ) + i \, {\left (\cos \left (2 \, d x + 2 \, c\right )^{2} + \sin \left (2 \, d x + 2 \, c\right )^{2} + 2 \, \cos \left (2 \, d x + 2 \, c\right ) + 1\right )}^{\frac {1}{2} \, n} a^{n} e^{4} \sin \left (n \arctan \left (\sin \left (2 \, d x + 2 \, c\right ), \cos \left (2 \, d x + 2 \, c\right ) + 1\right )\right ) - {\left (a^{n} e^{4} n - 3 \, a^{n} e^{4}\right )} {\left (\cos \left (2 \, d x + 2 \, c\right )^{2} + \sin \left (2 \, d x + 2 \, c\right )^{2} + 2 \, \cos \left (2 \, d x + 2 \, c\right ) + 1\right )}^{\frac {1}{2} \, n} \cos \left (2 \, d x + n \arctan \left (\sin \left (2 \, d x + 2 \, c\right ), \cos \left (2 \, d x + 2 \, c\right ) + 1\right ) + 2 \, c\right ) + {\left (-i \, a^{n} e^{4} n + 3 i \, a^{n} e^{4}\right )} {\left (\cos \left (2 \, d x + 2 \, c\right )^{2} + \sin \left (2 \, d x + 2 \, c\right )^{2} + 2 \, \cos \left (2 \, d x + 2 \, c\right ) + 1\right )}^{\frac {1}{2} \, n} \sin \left (2 \, d x + n \arctan \left (\sin \left (2 \, d x + 2 \, c\right ), \cos \left (2 \, d x + 2 \, c\right ) + 1\right ) + 2 \, c\right )\right )}}{{\left ({\left (-i \, e^{2 \, n} n^{2} + 5 i \, e^{2 \, n} n - 6 i \, e^{2 \, n}\right )} 2^{n} \cos \left (6 \, d x + 6 \, c\right ) - 3 \, {\left (i \, e^{2 \, n} n^{2} - 5 i \, e^{2 \, n} n + 6 i \, e^{2 \, n}\right )} 2^{n} \cos \left (4 \, d x + 4 \, c\right ) - 3 \, {\left (i \, e^{2 \, n} n^{2} - 5 i \, e^{2 \, n} n + 6 i \, e^{2 \, n}\right )} 2^{n} \cos \left (2 \, d x + 2 \, c\right ) + {\left (e^{2 \, n} n^{2} - 5 \, e^{2 \, n} n + 6 \, e^{2 \, n}\right )} 2^{n} \sin \left (6 \, d x + 6 \, c\right ) + 3 \, {\left (e^{2 \, n} n^{2} - 5 \, e^{2 \, n} n + 6 \, e^{2 \, n}\right )} 2^{n} \sin \left (4 \, d x + 4 \, c\right ) + 3 \, {\left (e^{2 \, n} n^{2} - 5 \, e^{2 \, n} n + 6 \, e^{2 \, n}\right )} 2^{n} \sin \left (2 \, d x + 2 \, c\right ) + {\left (-i \, e^{2 \, n} n^{2} + 5 i \, e^{2 \, n} n - 6 i \, e^{2 \, n}\right )} 2^{n}\right )} d} \]

[In]

integrate((e*sec(d*x+c))^(4-2*n)*(a+I*a*tan(d*x+c))^n,x, algorithm="maxima")

[Out]

8*((cos(2*d*x + 2*c)^2 + sin(2*d*x + 2*c)^2 + 2*cos(2*d*x + 2*c) + 1)^(1/2*n)*a^n*e^4*cos(n*arctan2(sin(2*d*x
+ 2*c), cos(2*d*x + 2*c) + 1)) + I*(cos(2*d*x + 2*c)^2 + sin(2*d*x + 2*c)^2 + 2*cos(2*d*x + 2*c) + 1)^(1/2*n)*
a^n*e^4*sin(n*arctan2(sin(2*d*x + 2*c), cos(2*d*x + 2*c) + 1)) - (a^n*e^4*n - 3*a^n*e^4)*(cos(2*d*x + 2*c)^2 +
 sin(2*d*x + 2*c)^2 + 2*cos(2*d*x + 2*c) + 1)^(1/2*n)*cos(2*d*x + n*arctan2(sin(2*d*x + 2*c), cos(2*d*x + 2*c)
 + 1) + 2*c) + (-I*a^n*e^4*n + 3*I*a^n*e^4)*(cos(2*d*x + 2*c)^2 + sin(2*d*x + 2*c)^2 + 2*cos(2*d*x + 2*c) + 1)
^(1/2*n)*sin(2*d*x + n*arctan2(sin(2*d*x + 2*c), cos(2*d*x + 2*c) + 1) + 2*c))/(((-I*e^(2*n)*n^2 + 5*I*e^(2*n)
*n - 6*I*e^(2*n))*2^n*cos(6*d*x + 6*c) - 3*(I*e^(2*n)*n^2 - 5*I*e^(2*n)*n + 6*I*e^(2*n))*2^n*cos(4*d*x + 4*c)
- 3*(I*e^(2*n)*n^2 - 5*I*e^(2*n)*n + 6*I*e^(2*n))*2^n*cos(2*d*x + 2*c) + (e^(2*n)*n^2 - 5*e^(2*n)*n + 6*e^(2*n
))*2^n*sin(6*d*x + 6*c) + 3*(e^(2*n)*n^2 - 5*e^(2*n)*n + 6*e^(2*n))*2^n*sin(4*d*x + 4*c) + 3*(e^(2*n)*n^2 - 5*
e^(2*n)*n + 6*e^(2*n))*2^n*sin(2*d*x + 2*c) + (-I*e^(2*n)*n^2 + 5*I*e^(2*n)*n - 6*I*e^(2*n))*2^n)*d)

Giac [F]

\[ \int (e \sec (c+d x))^{4-2 n} (a+i a \tan (c+d x))^n \, dx=\int { \left (e \sec \left (d x + c\right )\right )^{-2 \, n + 4} {\left (i \, a \tan \left (d x + c\right ) + a\right )}^{n} \,d x } \]

[In]

integrate((e*sec(d*x+c))^(4-2*n)*(a+I*a*tan(d*x+c))^n,x, algorithm="giac")

[Out]

integrate((e*sec(d*x + c))^(-2*n + 4)*(I*a*tan(d*x + c) + a)^n, x)

Mupad [B] (verification not implemented)

Time = 7.47 (sec) , antiderivative size = 174, normalized size of antiderivative = 1.78 \[ \int (e \sec (c+d x))^{4-2 n} (a+i a \tan (c+d x))^n \, dx=\frac {4\,e^4\,{\left (\frac {a\,\left (\cos \left (2\,c+2\,d\,x\right )+1+\sin \left (2\,c+2\,d\,x\right )\,1{}\mathrm {i}\right )}{\cos \left (2\,c+2\,d\,x\right )+1}\right )}^n\,\left (4\,\sin \left (2\,c+2\,d\,x\right )+\cos \left (2\,c+2\,d\,x\right )\,4{}\mathrm {i}+\cos \left (4\,c+4\,d\,x\right )\,1{}\mathrm {i}-n\,1{}\mathrm {i}+\sin \left (4\,c+4\,d\,x\right )-n\,\cos \left (2\,c+2\,d\,x\right )\,1{}\mathrm {i}-n\,\sin \left (2\,c+2\,d\,x\right )+3{}\mathrm {i}\right )}{d\,{\left (\frac {e}{\cos \left (c+d\,x\right )}\right )}^{2\,n}\,\left (4\,\cos \left (2\,c+2\,d\,x\right )+\cos \left (4\,c+4\,d\,x\right )+3\right )\,\left (n^2-5\,n+6\right )} \]

[In]

int((e/cos(c + d*x))^(4 - 2*n)*(a + a*tan(c + d*x)*1i)^n,x)

[Out]

(4*e^4*((a*(cos(2*c + 2*d*x) + sin(2*c + 2*d*x)*1i + 1))/(cos(2*c + 2*d*x) + 1))^n*(cos(2*c + 2*d*x)*4i - n*1i
 + cos(4*c + 4*d*x)*1i + 4*sin(2*c + 2*d*x) + sin(4*c + 4*d*x) - n*cos(2*c + 2*d*x)*1i - n*sin(2*c + 2*d*x) +
3i))/(d*(e/cos(c + d*x))^(2*n)*(4*cos(2*c + 2*d*x) + cos(4*c + 4*d*x) + 3)*(n^2 - 5*n + 6))